GBML manual / Audio

Sound and input

A map of the two ways a game talks to the player - sound out, buttons in - and which page covers which.

Two sides of a conversation

A game speaks to the player through what it plays, and it listens through the buttons. This section covers both, and they are separate topics with a page each.

You want toReadThe short version
Play a song, or a jump or coin noiseSound and musicOnly one song plays at a time. Short sound effects play on top of it, and many can play at once.
Know when the player pressed a buttonReading the buttonsA GBA has ten buttons. You can ask if one was just pressed, is being held, or was just released. These are three different questions.
Have a second player on a second consoleThe link cableTwo GBAs joined by a link cable share their buttons, so you can ask about player 2's buttons the way you ask about your own. Only buttons cross the cable.

What "input" means here

A GBA has no keyboard and no mouse. Everything the player does is one of ten buttons: A, B, L, R, Start, Select, and the four directions of the d-pad. Your code asks about them once every frame, which is one picture of the game. The GBA makes about 60 a second.

The same button can mean different things in different games, so GBML also lets you give a button a name for what it does, such as "jump", and lets the player change which button that is. That is covered on the Reading the buttons page, and action_rebind is the call that changes it.

What "sound" means here

Music and sound effects are different kinds of file, and GBML treats them as different things with different functions. The Sound and music page explains why, how fades work, and how to bend a song's speed or pitch while it plays.

Where they meet

Both belong to the game's frame. The order of a frame shows exactly when your code reads the buttons, and Core basics covers pausing, which stops button events but lets sound keep going.

See also: Sound and musicReading the buttonsThe link cableaction_rebindThe order of a framegame_pause